#!/usr/bin/env python3
# coding:utf-8
import paho.mqtt.client as mqtt

def on_connect(client,userdata,flags,rc):
    print("connect with result code: "+str(rc))
    
def on_message(client,userdata,msg):
    print("message received: "+msg.topic+" "+str(msg.payload))

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("127.0.0.1",1883,200)
client.subscribe("test/aaa",qos=0)
client.loop_forever()